﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <script src="~/Scripts/jquery-1.8.2.js"></script>
    <title>ModiFica</title>
</head>
<body>
    <input id="Hidden1" type="hidden" value="@ViewBag.id" />
    <div>
        <h1>Application Area</h1>
        <table width="1100" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#333333">
            <tr>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>员工编号</h3></td>
                <td width="220" height="60" align="center" valign="middle" bgcolor="#FFFFFF"><h3>员工姓名</h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>职位</h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>部门</h3></td>
               
            </tr>
            <tr>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="id" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
                <td width="220" height="60" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="name" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="zq" type="hidden" /><input type="text" id="Qianzw1" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="bq" type="hidden" /><input id="Qianbm1" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
               
            </tr>
        </table>
        <br />
        <table width="1100" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#333333">
            <tr>
                <td height="60" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:20px">
                  <h3>
                        变更选择：<input id="Radio1" type="radio" value="1" name="rid" onclick="funbian1()"  />晋升 <input id="Radio2" type="radio" name="rid" value="2" onclick="funbian2()" />降职 <input id="Radio3" type="radio" value="3" />其他
                        <span>
                            内部调动:<select id="Select1" onchange="funnei()">
                                <option value="0">请选择</option>
                            </select>
                        </span>
                    </h3>
                </td>
            </tr>
        </table>
        <br />
        <table width="1100" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#333333">
            <tr>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>变动详情</h3></td>
                <td width="220" height="60" align="center" valign="middle" bgcolor="#FFFFFF"><h3>变动前</h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>变动后</h3></td>
            </tr>
            <tr>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>部门</h3></td>
                <td width="220" height="60" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="Qianbm2" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="bh" type="hidden" /><input id="bmhou" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
            </tr>
            <tr>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3>职位</h3></td>
                <td width="220" height="60" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input type="text" id="Qianzw2" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /> </h3></td>
                <td width="220" align="center" valign="middle" bgcolor="#FFFFFF"><h3><input id="zh" type="hidden" /><input id="zwhou" type="text" onfocus=this.blur() style="border:0px; text-align:center; font-weight:bold; font-size:18px" /></h3></td>
            </tr>
           
        </table>
        <table width="1100" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#333333">
            <tr>
                <td height="60" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:20px">
                    <img src="~/Modi_Img/申请理由.png" />
                </td>
                <td height="60" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:20px">
                    <textarea rows="5"  id="reasn" cols="30" style="border:0px;  font-weight:bold; font-size:18px;width:auto;width:746px;height:245px"></textarea>
                </td>
            </tr>
        </table>
        <table width="1100" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#333333">
            <tr>
                <td height="60" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:20px">
                    <span style="font-size:24px;margin-left:450px"><a href="#" onclick="Add()">提交</a></span>
                    <span style="font-size:24px;margin-left:80px"><a href="#" onclick="outadd()">返回</a></span> 
                </td>
               
            </tr>
        </table>
    </div>
</body>
</html>
<script>

    $(function () {
        $.ajax({
            url: "/ModiFication/DeptList",
            success:function(obj)
            {
                obj = JSON.parse(obj)
                for (var i = 0; i < obj.length; i++) {
                    $("#Select1").append(" <option value='" + obj[i].DeptID + "'>" + obj[i].DeptName + "</option>")
                }
            }
        })
    })
    $(function () {
        var EmployID = $("#Hidden1").val();
        $.ajax({
            url: "/ModiFication/EmployeIf",
            data: { EmployID: EmployID },
            success:function(obj)
            {
                obj = JSON.parse(obj);
               
                $("#id").val(obj.EmployID);
                $("#name").val(obj.EmployName)
               
                $("#Qianzw1").val(obj.PositionName)
                $("#Qianbm1").val(obj.DeptName)
                $("#Qianzw2").val(obj.PositionName)
                $("#Qianbm2").val(obj.DeptName)
                $("#zq").val(obj.PositionID)
                $("#bq").val(obj.DeptID);
               

            }

        })
    })
    function funbian1() {

        var id = $(":radio:checked").val();
        var PositionID = $("#zq").val();
        $.ajax({
            url: "/ModiFication/PosiIf",
            data: { id: id, PositionID: PositionID },
            success:function(obj)
            {
           
                obj = JSON.parse(obj)
                $("#zh").val(obj.PositionID)
                $("#zwhou").val(obj.PositionName)
               
            }
        })
    }
    function funbian2() {
        var id = $(":radio:checked").val();
        var PositionID = $("#zq").val();
       
        $.ajax({
            url: "/ModiFication/PosiIf",
            data: { id: id, PositionID: PositionID },
            success: function (obj) {
                obj = JSON.parse(obj);
               
                $("#zwhou").val(obj.PositionName);
                $("#zh").val(obj.PositionID)
               
            }
        })
    }
    function funnei()
    {   
        var Altername = $("#Select1 :checked").val();
     
        if(Altername==0)
        {
            $("#bmhou").val($("#Qianbm2").val());
            return;
        }
        else {
            $.ajax({
                url: "/ModiFication/Dep",
                data: { id: Altername },
                success:function(obj)
                {
                    alert(obj)
                    obj = JSON.parse(obj)
                    $("#bmhou").val(obj.DeptName);
                    $("#bh").val(obj.DeptID);
                }
            })
           
        }

    }
    function Add()
    {
        var DeptLasr_Id = $("#bh").val();
        var PositionLast_Id = $("#zh").val();
        var EmployID = $("#id").val();
        var DeptBefore_Id = $("#bq").val();
        var ChangeStatu = $(":radio:checked").val();
        var Change_Reason = $("#reasn").val();
        var PositionBefore_Id = $("#zq").val();
        

        $.ajax({
            url: "/ModiFication/AddPerson",
            data: { DeptLasr_Id: DeptLasr_Id, PositionLast_Id: PositionLast_Id, EmployID: EmployID, DeptBefore_Id: DeptBefore_Id, ChangeStatu: ChangeStatu, Change_Reason: Change_Reason, PositionBefore_Id: PositionBefore_Id },
            success:function(obj)
            {
                alert(obj)
                if(obj>0)
                {
                    alert("tian")
                }
                else {
                    alert("123")
                }
            }
        })


    }
    function outadd()
    {
        location.href = "/ModiFication/Index";
    }


</script>
